package com.wgchao.mdmp.api;

import com.alibaba.fastjson.JSONObject;
import com.arronlong.httpclientutil.common.HttpResult;
import com.wgchao.mdmp.LogRecordAspect;
import com.wgchao.mdmp.common.ResultCommon;
import com.wgchao.mdmp.common.http.HttpClientUtil;
import com.wgchao.mdmp.common.http.HttpConfigParam;
import com.wgchao.mdmp.mapstruct.dto.MdmpGrxxDTO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

/**
 * @作者：wgchao
 * @时间：20:26 2019/11/10 0010
 * @用途：
 **/
@Service
public class GrxxHttp {
    private static final Logger logger = LoggerFactory.getLogger(GrxxHttp.class);
    /**
     * 获取患者信息
     * @param idcard
     * @return
     */
    public MdmpGrxxDTO searchPatientInfo(String idcard) throws Exception{
        try {
            String url = "http://127.0.0.1:8086/patient/manager/search/37028419587458425";

            HttpConfigParam httpConfigParam = HttpConfigParam.instanceOfGet(url);
            HttpResult respResult = HttpClientUtil.doHttp(httpConfigParam);
            ResultCommon<MdmpGrxxDTO> result = JSONObject.parseObject(respResult.getResult(), ResultCommon.class);
            if(result.getCode().equals("200")){
                return result.getData();
            }else{
                throw new Exception("获取患者信息失败");
            }
        }catch (Exception ex){
            logger.error(ex.getMessage());
            throw new Exception("获取患者信息失败");
        }
    }
}
